package com.zbkj.admin.controller.ai;

import com.zbkj.common.model.system.SystemAttachment;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.service.service.ai.AiProtraitHairstyleGenerateService;
import com.zbkj.service.service.ai.enums.AiPhgConfigEnum;
import com.zbkj.service.service.ai.request.AiHairstyleMaterialsCallbackRequest;
import com.zbkj.service.service.ai.request.AiHairstyleMaterialsRequest;
import com.zbkj.service.service.ai.response.AiHairestyleMaterialsAddAiMaterialsResponse;
import com.zbkj.service.service.publics.attachment.SystemAttachmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("api/admin/ai-hairstyle-materials")
@Api(tags = "Ai发型素材管理")
public class AiHairstyleMaterialsController {

    @Autowired
    private SystemAttachmentService systemAttachmentService;

    @Autowired
    private AiProtraitHairstyleGenerateService aiProtraitHairstyleGenerateService;

    @ApiOperation(value = "Ai发型素材管理-分页列表")
    @RequestMapping(value = "/getPageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<SystemAttachment>> getPageList(@Validated PageParamRequest pageParamRequest) {
        String pid = systemAttachmentService.getConfigPid(AiPhgConfigEnum.ai_attid_pid_hm.name());
        List<SystemAttachment> list =  systemAttachmentService.getList(
                Integer.valueOf(pid),
                null,
                pageParamRequest);
        CommonPage<SystemAttachment> systemAttachmentCommonPage = CommonPage.restPage(list);
        return CommonResult.success(systemAttachmentCommonPage);
    }

    @ApiOperation(value = "Ai发型素材管理-接收ai发型素材-提取特征回调接口")
    @RequestMapping(value = "/callbackAiHm", method = RequestMethod.POST)
    public CommonResult<Boolean> callbackAiHm(@RequestBody @Validated AiHairstyleMaterialsCallbackRequest imageVo) {
        return CommonResult.success(aiProtraitHairstyleGenerateService.callbackAiHm(imageVo));
    }

    @ApiOperation(value="Ai发型素材管理-新增并注册发型素材特征（ai目标注册提取特征接口）")
    @PostMapping(value = "/addAiMaterials")
    public CommonResult<AiHairestyleMaterialsAddAiMaterialsResponse> addAiMaterials(
            @RequestBody @Validated AiHairstyleMaterialsRequest request){
        return CommonResult.success(aiProtraitHairstyleGenerateService.addAiMaterials(request));
    }

}
